// 导入路由
import { BrowserRouter as Router, Route, Switch, Redirect } from 'react-router-dom'
// 导入页面组件
// import Login from './pages/Login'
// import Layout from './pages/GeekLayout/GeekLayout'
import { AuthRoute } from './components/AuthRoute'
import Publish from './pages/Publish/Publish'
import Article from './pages/Article/Article'
import { lazy, Suspense } from 'react'
const Login = lazy(() => import('./pages/Login'))
const Layout = lazy(() => import('./pages/GeekLayout/GeekLayout'))
import Lod from './assets/log.jpg'
// 配置路由规则
function App() {
  return (
    <Router>
      <div className="App">
        <Suspense fallback={<div className='loading'><img src={Lod} alt="" /></div>}>
          <Switch>
            <Route path="/login" component={Login}></Route>
            <Route path="/publish/:id" component={Publish}></Route>
            <Route path="/article" component={Article}></Route>
            <AuthRoute path="/home" component={Layout}></AuthRoute>
            <Redirect path="/" to="/home" />
          </Switch>
        </Suspense>
      </div>
    </Router>
  )
}

export default App